package com.ajk.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ajk.server.dao.TreatmentPicMapper;
import com.ajk.server.model.TreatmentPic;
import com.ajk.server.model.query.TreatmentPicQuery;
import com.ajk.server.service.TreatmentPicService;

/**
 * 就诊图片  <br>
 * t_treatment_pic <br>
 * v1.0 2016-05-01
 */
 @Service
 public class TreatmentPicServiceImpl implements TreatmentPicService {
	
	private static final Logger logger = LoggerFactory.getLogger(TreatmentPicServiceImpl.class);
	
	@Autowired
	private TreatmentPicMapper treatmentPicMapper;
	
	/**
 	*根据ID删除 就诊图片
 	*/
 	@Override
 	public Integer deleteTreatmentPicById(Integer id){
 		return treatmentPicMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 就诊图片
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertTreatmentPic(List<? extends TreatmentPic> treatmentPics){
		Integer count = treatmentPicMapper.batchInsert(treatmentPics);
		return count;
 	}
 	/**
 	*新增 就诊图片
 	*/
 	@Override
 	@Transactional
 	public Integer insertTreatmentPic(TreatmentPic domain){
		Integer id = treatmentPicMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 就诊图片
 	*/
 	@Override
 	@Transactional
 	public Integer updateTreatmentPic(TreatmentPic domain){
		Integer count = treatmentPicMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 就诊图片
 	*/
 	public TreatmentPic findTreatmentPicById(Integer id){
 		TreatmentPic result = treatmentPicMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 就诊图片
 	*/
	public List<TreatmentPic> findTreatmentPicByQuery(TreatmentPicQuery query){
		query.dealWith();
		List<TreatmentPic> result = treatmentPicMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (TreatmentPic treatmentPic : result) {
				treatmentPic.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countTreatmentPicByQuery(TreatmentPicQuery query){
 		query.dealWith();
 		Integer result = treatmentPicMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<TreatmentPic> findTreatmentPicByIds(List<Integer> ids){
 		List<TreatmentPic> result = treatmentPicMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (TreatmentPic treatmentPic : result) {
				treatmentPic.dealWith();
			}
		}
		return result;
 	}
 	
}	